// 04jyhs/orderAdmin/orderAdmin.js
var co = require('../../resource/js/common.js')
var app = getApp()
var _this, _data
var _pageNum = 1
Page({
   data: {
      //订单列表
      orderList: [],
      //是否隐藏显示底部提示
      hint: true,
      //frame高度
      frame_h: 1800
   },
   onLoad: function (opt) {
      _this = this;
      _data = this.data;
      _this.setData({
         frame_h: wx.getSystemInfoSync().windowHeight + 10
      })
      _this.getOrderList()
   },
   onUnload: function () {
      _pageNum = 1
   },


   onReachBottom: function () {
      _this.getOrderList()
   },

   //获取订单列表
   getOrderList: function () {
      wx.showLoading({
         title: '正在加载数据中...',
      })
      co.getJyhsApi('order/Order/getOrderList', {
         page: _pageNum
      }, function (res) {
         wx.hideLoading()
         if (res.code == 0) {
            var list = _data.orderList.concat(res.data)
            _this.setData({
               orderList: list
            })
            _pageNum++
         } else {
            _this.setData({
               hint: false
            })
            co.toastAllText(res.msg)
         }
      })
   },

   //item点击事件
   onClickItem: function (e) {
      console.log('e===', e)
      var index = e.currentTarget.dataset.index
      var orderID = _data.orderList[index].Order_ID
      wx.navigateTo({
         url: '/04jyhs/orderAdmin/orderAdminDetail/orderAdminDetail?orderID=' + orderID,
      })
   },
})